<?php
/*
+---------------------------------------------------------------+
|        e107 website system
|        Easy Admin Page by Cameron. (www.e107coders.org)
|        a part of Your_plugin v3.1  multilanguage by Juan  Reseau.li
|        Released under the terms and conditions of the
|        GNU General Public License (http://gnu.org).
|		 Suitable only for e107 v0.7
+---------------------------------------------------------------+
*/

require_once("../../class2.php");
if(!getperms("P")){ header("location:".e_BASE."index.php"); exit; }
require_once(e_ADMIN."header.php");


      $text = "<center><h3>e107 CMS integration plugin</h3></center><br/>";
     if(isset($_POST['submit'])) //if submit has been pushed to create a monster
     {

       $file=$_POST['file'];
	   $host=$_POST['host'];
	   $uname=$_POST['uname'];
	   $pass=$_POST['pass'];
	   $prefix=$_POST['prefix'];
	   $db=$_POST['db'];
	   $desc=$_POST['desc'];
	   $path=$_POST['path'];
       $checkname="SELECT * from e107_cipcms where path='$path'";
       $checkname2=mysql_query($checkname) or die("Could not query monsters");
       while($checkname3=mysql_fetch_array($checkname2))
       {
         $themonster=$checkname3[name];
       }
       if($themonster) 
       {
         $text .= "Sorry, you have already used the cms importation with $path";
       }
       else
       {
$sql = "INSERT INTO `e107_cipcms` (`file`, `cmshost`, `cmsuname`, `cmspass`, `cmsdb`, `path`, `descr`, `cmsprefix`) VALUES ('$file', '$host', '$uname', '$pass', '$db', '$path', '$desc','$prefix')";
        mysql_query($sql) or die("Could not create monster");
        $text .= "integrated $path!";
       }
 

     }
     
     else
    {
       
       $text .= "<form action='admin_new.php' method='post'>";
       $text .= "Welcome to the CMS Integration page. Please fill the fields:<br/>";
       $text .= "<hr/>CMS File:";
       $text .= "<input type='text' name='file' size='15'><br/>";
       $text .= "MySQL Host:";
       $text .= "<input type='text' name='host' size='15'><br/>";
       $text .= "MySQL Username:";
       $text .= "<input type='text' name='uname' size='15'><br/>";
       $text .= "MySQL Password:";
       $text .= "<input type='text' name='pass' size='15'><br/>";
       $text .= "MySQL DB:";
       $text .= "<input type='text' name='db' size='15'><br/>";
       $text .= "MySQL CMS DB Prefix:";
       $text .= "<input type='text' name='prefix' size='15'><br/>Not needed now.<hr/><br/>";
       $text .= "Name and/or Description:<br/>";
       $text .= "<input type='text' name='desc' size='15'><br/>";
       $text .= "CMS location: example: http://www.example.org/cms/<br/>";
       $text .= "<input type='text' name='path' size='15'><br/>";
       $text .= "Integration version: 1.0<br/>";
       $text .= "<input type='submit' name='submit' value='Create CMS integration'>";
       $text .= "</form>";  
    }

$ns -> tablerender("e107Cip - Admin", $text);

require_once(e_ADMIN."footer.php");

?>
